package com.trace.pplos.parse.dao.dataobject;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

public class GgaqdwInfo {
    private static final Logger logger = LoggerFactory.getLogger(GgaqdwInfo.class);

    private Integer id;

    private String unitType;

    private String photoPath;

    private String blastHeadCount;

    private String blastCount;

    private String securityOfficer;

    private String keeperCount;

    private String headName;

    private String headPhone;

    private String lng;

    private String lat;

    private String addr;

    private String lngGps;

    private String latGps;

    private String cjdw;

    private String filepath;

    private String locMapSnapPath;

    private Date gmtCreate;

    private String gmtCreateUser;

    private Date gmtModified;

    private String gmtModifiedUser;

    private Integer status;

    public GgaqdwInfo(Integer id, String unitType, String photoPath, String blastHeadCount, String blastCount, String securityOfficer, String keeperCount, String headName, String headPhone, String lng, String lat, String addr, String lngGps, String latGps, String cjdw, String filepath, String locMapSnapPath, Date gmtCreate, String gmtCreateUser, Date gmtModified, String gmtModifiedUser, Integer status) {
        this.id = id;
        this.unitType = unitType;
        this.photoPath = photoPath;
        this.blastHeadCount = blastHeadCount;
        this.blastCount = blastCount;
        this.securityOfficer = securityOfficer;
        this.keeperCount = keeperCount;
        this.headName = headName;
        this.headPhone = headPhone;
        this.lng = lng;
        this.lat = lat;
        this.addr = addr;
        this.lngGps = lngGps;
        this.latGps = latGps;
        this.cjdw = cjdw;
        this.filepath = filepath;
        this.locMapSnapPath = locMapSnapPath;
        this.gmtCreate = gmtCreate;
        this.gmtCreateUser = gmtCreateUser;
        this.gmtModified = gmtModified;
        this.gmtModifiedUser = gmtModifiedUser;
        this.status = status;
    }

    public GgaqdwInfo() {
        super();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUnitType() {
        return unitType;
    }

    public void setUnitType(String unitType) {
        this.unitType = unitType == null ? null : unitType.trim();
    }

    public String getPhotoPath() {
        return photoPath;
    }

    public void setPhotoPath(String photoPath) {
        this.photoPath = photoPath == null ? null : photoPath.trim();
    }

    public String getBlastHeadCount() {
        return blastHeadCount;
    }

    public void setBlastHeadCount(String blastHeadCount) {
        this.blastHeadCount = blastHeadCount == null ? null : blastHeadCount.trim();
    }

    public String getBlastCount() {
        return blastCount;
    }

    public void setBlastCount(String blastCount) {
        this.blastCount = blastCount == null ? null : blastCount.trim();
    }

    public String getSecurityOfficer() {
        return securityOfficer;
    }

    public void setSecurityOfficer(String securityOfficer) {
        this.securityOfficer = securityOfficer == null ? null : securityOfficer.trim();
    }

    public String getKeeperCount() {
        return keeperCount;
    }

    public void setKeeperCount(String keeperCount) {
        this.keeperCount = keeperCount == null ? null : keeperCount.trim();
    }

    public String getHeadName() {
        return headName;
    }

    public void setHeadName(String headName) {
        this.headName = headName == null ? null : headName.trim();
    }

    public String getHeadPhone() {
        return headPhone;
    }

    public void setHeadPhone(String headPhone) {
        this.headPhone = headPhone == null ? null : headPhone.trim();
    }

    public String getLng() {
        return lng;
    }

    public void setLng(String lng) {
        this.lng = lng == null ? null : lng.trim();
    }

    public String getLat() {
        return lat;
    }

    public void setLat(String lat) {
        this.lat = lat == null ? null : lat.trim();
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr == null ? null : addr.trim();
    }

    public String getLngGps() {
        return lngGps;
    }

    public void setLngGps(String lngGps) {
        this.lngGps = lngGps == null ? null : lngGps.trim();
    }

    public String getLatGps() {
        return latGps;
    }

    public void setLatGps(String latGps) {
        this.latGps = latGps == null ? null : latGps.trim();
    }

    public String getCjdw() {
        return cjdw;
    }

    public void setCjdw(String cjdw) {
        this.cjdw = cjdw == null ? null : cjdw.trim();
    }

    public String getFilepath() {
        return filepath;
    }

    public void setFilepath(String filepath) {
        this.filepath = filepath == null ? null : filepath.trim();
    }

    public String getLocMapSnapPath() {
        return locMapSnapPath;
    }

    public void setLocMapSnapPath(String locMapSnapPath) {
        this.locMapSnapPath = locMapSnapPath == null ? null : locMapSnapPath.trim();
    }

    public Date getGmtCreate() {
        return gmtCreate;
    }

    public void setGmtCreate(Date gmtCreate) {
        this.gmtCreate = gmtCreate;
    }

    public String getGmtCreateUser() {
        return gmtCreateUser;
    }

    public void setGmtCreateUser(String gmtCreateUser) {
        this.gmtCreateUser = gmtCreateUser == null ? null : gmtCreateUser.trim();
    }

    public Date getGmtModified() {
        return gmtModified;
    }

    public void setGmtModified(Date gmtModified) {
        this.gmtModified = gmtModified;
    }

    public String getGmtModifiedUser() {
        return gmtModifiedUser;
    }

    public void setGmtModifiedUser(String gmtModifiedUser) {
        this.gmtModifiedUser = gmtModifiedUser == null ? null : gmtModifiedUser.trim();
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public static GgaqdwInfo toBean(String object){
        try{
            GgaqdwInfo info = new GgaqdwInfo();
            JSONObject record = JSON.parseObject(object);
            info.setUnitType(record.getString("hylx"));
            info.setHeadName(record.getString("fzrmc"));
            info.setHeadPhone(record.getString("lxdh"));
            info.setLng(record.getString("longitude"));
            info.setLat(record.getString("latitude"));
            info.setAddr(record.getString("address"));

            //现场方位图
            String filePaths = "";
            JSONArray list = record.getJSONArray("xcfwPictureList");
            for (int i = 0; i < list.size(); i++) {
                JSONObject dataObj = list.getJSONObject(i);
                filePaths += dataObj.getString("path") +",";
            }
            info.setLocMapSnapPath(filePaths);
            //外部概览图
            filePaths = "";
            list = record.getJSONArray("wbglPictureList");
            for (int i = 0; i < list.size(); i++) {
                JSONObject dataObj = list.getJSONObject(i);
                filePaths += dataObj.getString("path") +",";
            }
            info.setPhotoPath(filePaths);

            info.setGmtCreate(record.getDate("createdAt"));
            info.setGmtCreateUser(record.getString("createdBy"));
            //info.setGmtModified(record.getDate("modifiedAt"));
            info.setGmtModified(new Date());
            info.setGmtModifiedUser(record.getString("modifiedBy"));
            return info;
        }catch (Exception e){
            logger.error(e.getMessage(), e);
        }
        return null;
    }
}